/*
 * 1456. 引用
 * 实现一个类 ReferenceManager 包含如下两种方法
 * 1.copyValue(Node obj) 只拷贝参数obj的权值，obj和node仍然是两个指针
 * 2.copyReference(Node obj) obj和node指向同一个地方
 * https://www.lintcode.com/problem/reference/description
 * 
 * 样例
 * ReferenceManager ref = ReferenceManager();
 * Node obj = new Node(0);
 * ref.copyValue(obj);
 * ref.node.val; // will be 0
 * ref.node; // will be different with obj.
 * Node obj2 = new Node(1);
 * ref.copyReference(obj2);
 * ref.node.val; // will be 1
 * ref.node; // will be the same with obj2
 * 
 * 2018.06.10 @jeyming
 */
package reference_1456;

//Definition of Node:
class Node {
	public int val;
	public Node(int val) {
		this.val = val;
	}
}

class ReferenceManager {
    public Node node;

    public void copyValue(Node obj) {
        // copy value from obj to node
    	if(obj == null)
    		return;
    	if(node == null)
    		node = new Node(obj.val);
    }

    public void copyReference(Node obj) {
        // copy reference from obj to node
    	node = obj;
    }
    
   
}

public class Reference_1456 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		

	}

}
